package com.company.app.daoImpl;

import java.util.List;

import com.company.app.dao.AbstractBaseDAO;
import com.company.app.dao.ProductTypeDAO;
import com.company.app.entities.ProductType;
import com.google.code.ssm.api.InvalidateSingleCache;
import com.google.code.ssm.api.ParameterValueKeyProvider;
import com.google.code.ssm.api.ReadThroughMultiCache;
import com.google.code.ssm.api.ReadThroughMultiCacheOption;
import com.google.code.ssm.api.ReadThroughSingleCache;
import com.google.code.ssm.api.ReturnDataUpdateContent;
import com.google.code.ssm.api.UpdateSingleCache;

/**
 * The Class ProductTypeDAOImpl.
 */
public class ProductTypeDAOImpl extends AbstractBaseDAO<ProductType> implements
		ProductTypeDAO {

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.company.app.dao.BaseInterfaceDAO#getEntityById(java.lang.Long)
	 */
	@Override
	@ReadThroughSingleCache(namespace = MEMCHACHED_NAMESPACE, expiration = 60)
	public ProductType getEntityById(@ParameterValueKeyProvider Long id) {
		return this.getSqlSession().selectOne(
				"com.company.app.dao.ProductTypeMapper.getProductTypeById", id);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.company.app.dao.BaseInterfaceDAO#getAllEntity()
	 */
	@Override
	public List<ProductType> getAllEntity() {
		return this.getSqlSession().selectList(
				"com.company.app.dao.ProductTypeMapper.getAllProductType");
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.company.app.dao.BaseInterfaceDAO#searchEntityByFilter(java.lang.Object
	 * )
	 */
	@Override
	@ReadThroughMultiCache(namespace = MEMCHACHED_NAMESPACE, expiration = 180, option = @ReadThroughMultiCacheOption(generateKeysFromResult = true,skipNullsInResult=true))
	public List<ProductType> searchEntities(
			@ParameterValueKeyProvider List<ProductType> filter) {
		return this.getSqlSession().selectList(
				"com.company.app.dao.ProductTypeMapper.getProductTypeByFilter",filter.get(0));
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.company.app.dao.AbstractBaseDAO#updateEntity(java.lang.Object)
	 */
	@Override
	@UpdateSingleCache(namespace = MEMCHACHED_NAMESPACE, expiration = 180)
	@ReturnDataUpdateContent
	public ProductType updateEntity(@ParameterValueKeyProvider ProductType entity) {
		return super.updateEntity(entity);
	}
	
	/* (non-Javadoc)
	 * @see com.company.app.dao.AbstractBaseDAO#deleteEntity(java.lang.Object)
	 */
	@Override
	@InvalidateSingleCache(namespace = MEMCHACHED_NAMESPACE)
	public ProductType deleteEntity(@ParameterValueKeyProvider ProductType entity) {
		return super.deleteEntity(entity);
	}
	
	@Override
	@UpdateSingleCache(namespace = MEMCHACHED_NAMESPACE)
	@ReturnDataUpdateContent
	public ProductType createEntity(@ParameterValueKeyProvider ProductType entity) {
		return super.createEntity(entity);
	}


}
